package com.commpany.servie.basic.promotion.business.read.productPromotionMap.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.commpany.jdq.core.orm.Pagination;
import com.commpany.servie.basic.promotion.business.read.productPromotionMap.ProductPromotionMapReadManage;
import com.commpany.servie.basic.promotion.dao.read.ProductPromotionMapReadDAO;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import com.commpany.jdq.core.common.PageResult;
import com.commpany.jdq.core.common.BaseReadManager;
import com.commpany.servie.basic.promotion.po.ProductPromotionMapPO;
@Slf4j
@Service
public class ProductPromotionMapReadManageImpl extends BaseReadManager<ProductPromotionMapPO> implements ProductPromotionMapReadManage {
	@Autowired
	private ProductPromotionMapReadDAO productPromotionMapReadDAO;
	
	@Override
    public ProductPromotionMapPO getProductPromotionMapService(ProductPromotionMapPO po){
                 checkParams(po);
         return  productPromotionMapReadDAO.findById(po);
    }
    @Override
	public PageResult<ProductPromotionMapPO> selectProductPromotionMapPageService(ProductPromotionMapPO po, Pagination page){
	       checkParams(po);
	    page.setLimitStart((page.getPageNo() - 1) * page.getPageSize());
		PageResult<ProductPromotionMapPO> result = new PageResult<ProductPromotionMapPO>();
		List<ProductPromotionMapPO> list = productPromotionMapReadDAO.findOfPage(po, page);
		int count = productPromotionMapReadDAO.countOfPage(po);
		result.setList(list);
		result.setTotalSize(count);
		result.copy(page);
		return result;
		
	}
	
    @Override
	public int countProductPromotionMapService( ProductPromotionMapPO po ){
	            checkParams(po);
	    return productPromotionMapReadDAO.countOfPage(po);
	
	}
	
    @Override
	public List<ProductPromotionMapPO> queryProductPromotionMapService(ProductPromotionMapPO po){
	            checkParams(po);
	   return  productPromotionMapReadDAO.findAll(po);
	}
	
}
	